/*     */ package net.sourceforge.appgen.util;
/*     */ 
/*     */ import java.io.File;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Collections;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import net.sourceforge.appgen.converter.FirstCharacterUpperCaseConverter;
/*     */ import net.sourceforge.appgen.converter.StringConverter;
/*     */ 
/*     */ public abstract class ConventionUtils
/*     */ {
/*  34 */   private static StringConverter firstCharacterUpperCaseConverter = new FirstCharacterUpperCaseConverter();
/*     */   public static final String FIXME = "// FIXME: Entity generator.";
/*  38 */   public static final String[] RESERVED_WORDS = { 
/*  40 */     "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "continue", "default", "do", "double", "else", 
/*  41 */     "enum", "extends", "false", "final", "finally", "float", "for", "if", "implements", "import", "instanceof", "int", "interface", 
/*  42 */     "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "strictfp", "super", 
/*  43 */     "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while", 
/*  44 */     "const", "goto", 
/*  46 */     "serializable", "serialVersionUID", 
/*  47 */     "logger", "logFactory", 
/*  48 */     "obj", "result", "prime", 
/*  49 */     "assert", "errors", "validationUtils", 
/*  50 */     "dataAccessException", "actualRowsAffected", 
/*  51 */     "httpServletRequest", "httpServletResponse", 
/*  52 */     "modelAndView", "servletRequestUtils", "servletRequestUtils", 
/*  53 */     "servletRequestDataBinder", "binder", "bindException", "errors", "customDateEditor", 
/*  54 */     "sqlMapClientDaoSupport", 
/*  55 */     "list", "map", "linkedHashMap", "param", "date", "simpleDateFormat", 
/*  56 */     "controller", "simpleFormController", "service", "serviceImpl", "dao", "daoImpl", "criteria", "validator", "paging", 
/*  57 */     "request", "response", "mav", "mode", "totalResults", "command", 
/*  58 */     "attachFilePersister", "attachFilePropertyEditor", "fileSystemResource", "saveResource", 
/*  59 */     "attachFile" };
/*     */ 
/*     */   public static boolean isReservedWord(String s)
/*     */   {
/*  63 */     for (String word : RESERVED_WORDS) {
/*  64 */       if (word.equals(s)) {
/*  65 */         return true;
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/*  70 */     return isJavaLangClass(s);
/*     */   }
/*     */ 
/*     */   public static boolean isJavaLangClass(String s)
/*     */   {
/*  77 */     if (s == null) {
/*  78 */       return false;
/*     */     }
/*     */ 
/*  81 */     boolean exist = false;
/*     */     try
/*     */     {
/*  84 */       Class.forName("java.lang." + firstCharacterUpperCaseConverter.convert(s));
/*  85 */       exist = true;
/*     */     }
/*     */     catch (ClassNotFoundException localClassNotFoundException) {
/*     */     }
/*  89 */     return exist;
/*     */   }
/*     */ 
/*     */   public static String getPath(String packageName) {
/*  93 */     if (packageName == null) {
/*  94 */       return packageName;
/*     */     }
/*     */ 
/*  97 */     StringBuffer buffer = new StringBuffer();
/*  98 */     String[] packages = packageName.split("[.]");
/*     */ 
/* 100 */     for (String s : packages) {
/* 101 */       if (buffer.length() > 0) {
/* 102 */         buffer.append(File.separator);
/*     */       }
/*     */ 
/* 105 */       buffer.append(s);
/*     */     }
/*     */ 
/* 108 */     return buffer.toString();
/*     */   }
/*     */ 
/*     */   public static List<String> getImportDeclarations(List<String> classNameList, String exceptPackageName) {
/* 112 */     List list = new ArrayList();
/*     */ 
/* 114 */     Collections.sort(classNameList, new ClassNameComparator());
/*     */ 
/* 116 */     String previousFirstPackageName = null;
/* 117 */     for (String className : classNameList) {
/* 118 */       String firstPackageName = null;
/* 119 */       int firstIndex = className.indexOf('.');
/* 120 */       if (firstIndex > 0) {
/* 121 */         firstPackageName = className.substring(0, firstIndex);
/*     */       }
/*     */ 
/* 124 */       String packageName = getPackageName(className);
/*     */ 
/* 126 */       if ((exceptPackageName != null) && (!exceptPackageName.equals(packageName))) {
/* 127 */         if ((previousFirstPackageName != null) && (firstPackageName != null) && 
/* 128 */           (!firstPackageName.equals(previousFirstPackageName))) {
/* 129 */           list.add("");
/*     */         }
/*     */ 
/* 133 */         String importDeclaration = "import " + className + ";";
/* 134 */         if (!list.contains(importDeclaration)) {
/* 135 */           list.add("import " + className + ";");
/*     */         }
/*     */       }
/*     */ 
/* 139 */       previousFirstPackageName = firstPackageName;
/*     */     }
/*     */ 
/* 142 */     return list;
/*     */   }
/*     */ 
/*     */   public static String getSimpleClassName(String className) {
/* 146 */     if ((className == null) || (className.lastIndexOf('.') < 0) || (className.lastIndexOf('.') + 1 > className.length())) {
/* 147 */       return className;
/*     */     }
/*     */ 
/* 150 */     return className.substring(className.lastIndexOf('.') + 1);
/*     */   }
/*     */ 
/*     */   public static String getPackageName(String className) {
/* 154 */     if (className == null) {
/* 155 */       return null;
/*     */     }
/*     */ 
/* 158 */     int lastIndex = className.lastIndexOf('.');
/* 159 */     if (lastIndex > 0) {
/* 160 */       return className.substring(0, lastIndex);
/*     */     }
/*     */ 
/* 163 */     return null;
/*     */   }
/*     */ 
/*     */   public static boolean isLobColumn(int dataType) {
/* 167 */     boolean lob = false;
/*     */ 
/* 169 */     switch (dataType) {
/*     */     case 2004:
/* 171 */       lob = true;
/* 172 */       break;
/*     */     case 2005:
/* 174 */       lob = true;
/* 175 */       break;
/*     */     }
/*     */ 
/* 180 */     return lob;
/*     */   }
/*     */ 
/*     */   public static String getJavaType(int dataType, int columnSize, int decimalDegit) {
/* 184 */     String fieldType = String.class.getName();
/*     */ 
/* 186 */     switch (dataType) {
/*     */     case 2003:
/* 188 */       break;
/*     */     case -5:
/* 190 */       fieldType = "long";
/* 191 */       break;
/*     */     case -2:
/* 193 */       break;
/*     */     case -7:
				fieldType = "int";
/* 195 */       break;
/*     */     case 2004:
/* 197 */       break;
/*     */     case 16:
/* 199 */       fieldType = "boolean";
/* 200 */       break;
/*     */     case 1:
/* 202 */       break;
/*     */     case 2005:
/* 204 */       break;
/*     */     case 70:
/* 206 */       break;
/*     */     case 91:
/* 208 */       fieldType = Date.class.getName();
/* 209 */       break;
/*     */     case 3:
/* 211 */       if (decimalDegit > 0)
/* 212 */         fieldType = "double";
/*     */       else {
/* 214 */         fieldType = "int";
/*     */       }
/* 216 */       break;
/*     */     case 2001:
/* 218 */       break;
/*     */     case 8:
/* 220 */       fieldType = "double";
/* 221 */       break;
/*     */     case 6:
/* 223 */       fieldType = "float";
/* 224 */       break;
/*     */     case 4:
/* 226 */       fieldType = "int";
/* 227 */       break;
/*     */     case 2000:
/* 229 */       break;
/*     */     case -4:
/* 231 */       break;
/*     */     case -1:
/* 233 */       break;
/*     */     case 0:
/* 235 */       break;
/*     */     case 2:
/* 237 */       if (decimalDegit > 0)
/* 238 */         fieldType = "double";
/*     */       else {
/* 240 */         fieldType = "int";
/*     */       }
/* 242 */       break;
/*     */     case 1111:
/* 244 */       break;
/*     */     case 7:
/* 246 */       break;
/*     */     case 2006:
/* 248 */       break;
/*     */     case 5:
/* 250 */       fieldType = "int";
/* 251 */       break;
/*     */     case 2002:
/* 253 */       break;
/*     */     case 92:
/* 255 */       fieldType = Date.class.getName();
/* 256 */       break;
/*     */     case 93:
/* 258 */       fieldType = Date.class.getName();
/* 259 */       break;
/*     */     case -6:
/* 261 */       fieldType = "int";
/* 262 */       break;
/*     */     case -3:
/* 264 */       break;
/*     */     case 12:
/* 266 */       break;
/*     */     }
/*     */ 
/* 271 */     return fieldType;
/*     */   }
/*     */ }

/* Location:           C:\Users\lzl6066\Downloads\net.sourceforge.appgen_1.2.0\plugins\net.sourceforge.appgen_1.2.0.201002031718\
 * Qualified Name:     net.sourceforge.appgen.util.ConventionUtils
 * JD-Core Version:    0.6.0
 */